import Vue from 'vue'
import VueRouter from 'vue-router'

// 开发环境不使用懒加载
const _import = require('./import-' + process.env.NODE_ENV + '.js')

Vue.use(VueRouter)

/**
 * 全局路由无需嵌套sidebar navbar
 */
const globalRouters = [
]

/**
 * 主路由需嵌套sidebar navbar
 */
const mainRouters = [{
  path: '/',
  name: 'Mian',
  component: _import('Main'),
  redirect: { name: 'Home' },
  children: [
    {
      path: '/home',
      name: 'Home',
      component: _import('Home')
    },
    {
      path: '/articles/:id',
      name: 'Article',
      component: _import('Article'),
      props: true
    }
  ]
},
{
  path: '/heroes/:id',
  name: 'Hero',
  component: _import('Hero'),
  props: true
}]


const router = new VueRouter({
  base: process.env.BASE_URL,
  routes: mainRouters.concat(globalRouters)
})

export default router